package com.baidu.speech.qr_code.ui.notifications;

import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.baidu.speech.qr_code.R;
import com.baidu.speech.qr_code.ui.Entity_class.Password;
import com.baidu.speech.qr_code.ui.dashboard.Datazfh;

import org.litepal.LitePal;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

public class Notif_Historical_records extends AppCompatActivity {
    private ListView lv;
    private TextView tv_lsjl;
    private TextView tv_noitfcontent;
    private List<Datazfh>datazfhs=LitePal.findAll(Datazfh.class);


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notif__historical_records);
        initView();
    }

    private void initView() {
        lv = (ListView) findViewById(R.id.lv);
        MyAdapter myAdapter=new MyAdapter();
        lv.setAdapter(myAdapter);
        Collections.reverse(datazfhs);
        Toast.makeText(this, "调用", Toast.LENGTH_SHORT).show();
    }

    class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return datazfhs.size();
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            View view1 = View.inflate(Notif_Historical_records.this, R.layout.historical_records_son, null);
            tv_lsjl = view1.findViewById(R.id.tv_lsjl);
            tv_noitfcontent = view1.findViewById(R.id.tv_noitfcontent);
            tv_lsjl.setText(datazfhs.get(i).getTime());
            tv_noitfcontent.setText(datazfhs.get(i).getContent());
            return view1;
        }
    }
}